using ObjFileLoader.Common;
using ObjFileLoader.Data.DataStore;
using ObjFileLoader.Data.VertexData;
using ObjFileLoader.TypeParsers.Interfaces;

namespace ObjFileLoader.TypeParsers
{
	public class NormalParser : TypeParserBase, INormalParser, ITypeParser
	{
		private readonly INormalDataStore _normalDataStore;

		protected override string Keyword => "vn";

		public NormalParser(INormalDataStore normalDataStore)
		{
			_normalDataStore = normalDataStore;
		}

		public override void Parse(string line)
		{
			string[] array = line.Split(new char[1]
			{
				' '
			});
			float x = array[0].ParseInvariantFloat();
			float y = array[1].ParseInvariantFloat();
			float z = array[2].ParseInvariantFloat();
			Normal normal = new Normal(x, y, z);
			_normalDataStore.AddNormal(normal);
		}
	}
}
